test(tts): cover splitLongSpeechText / splitLongSpeechActions#694
Merged
Conversation
lib/audio/tts-utils.ts had no tests. Add coverage for the sentence -> clause -> hard-split chunking, the invariant that no chunk exceeds maxLength (nor is empty), and the splitLongSpeechActions contract (no-limit provider untouched; short/non-speech untouched; over-limit split into <id>_tts_<n> sub-actions with the parent audioId dropped and text preserved). Behavior verified against adversarial inputs first — no source change, coverage only. Closes THU-MAIC#693
wyuc
approved these changes
Jul 12, 2026
wyuc
left a comment
Contributor
There was a problem hiding this comment.
Focused review complete. The added coverage locks the important TTS splitting boundaries and invariants without changing production behavior. Verified on the latest main (including #696): targeted TTS utility tests pass 9/9 locally, the final diff contains only the new test file, and refreshed GitHub Lint/Typecheck/Unit and E2E checks are green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
lib/audio/tts-utils.ts(TTS text/action splitting on the generation + playback paths) had no test coverage. The sentence → clause → hard-split chunking with a per-provider length cap is edge-case-prone and worth a regression lock.Closes #693.
Coverage added (
tests/audio/tts-utils.test.ts, 9 cases)splitLongSpeechText: within-limit passthrough (trimmed), sentence-boundary split (punctuation kept), packing consecutive short sentences up to the limit, clause-punctuation fallback for over-long sentences, hard-splitting a punctuation-free run, and the invariant that no chunk exceedsmaxLength(and none is empty) across several limits.splitLongSpeechActions: provider with no limit → actions returned untouched (same ref); short speech + non-speech → untouched; over-limit speech → chunked sub-actions with<id>_tts_<n>ids, the parentaudioIddropped, each chunk ≤ limit, and the text preserved across the split.Note
No source change — coverage only. I verified the
maxLengthinvariant holds against adversarial inputs (long no-punctuation runs, clause-heavy text, boundary lengths) before locking it in tests, so this documents correct behavior rather than fixing a bug.tsc/prettier/eslintclean.